#include <bits/stdc++.h>
// 2025/01/21
// tag: 
// Author: Zhang Muen
using namespace std;

int n, parents[1000001];

class UF
{
public:
    int cnt;

    UF(int n)
    {
        cnt = n;
        for (int i = 0; i <= n; i++)
            parents[i] = i;
    };

    int find(int i)
    {
        if (parents[i] != i)
            return parents[i] = find(parents[i]);
        return parents[i];
    }

    void un(int i, int j)
    {
        int ri = find(i), rj = find(j);
        if (ri == rj)
            return;
        parents[ri] = rj;
        cnt--;
    }

    int count()
    {
        return cnt;
    }

    bool connected(int p, int q)
    {
        return find(p) == find(q);
    }
};

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    UF uf(n);
    for (int i = 1; i <= n; i++){
        int a;
        cin >> a;
        uf.un(i, a);
    }
    cout << uf.count() << endl;
    return 0;
}